package com.sdut.material.controller;


import com.sdut.material.pojo.Input;
import com.sdut.material.service.IInputService;
import com.sdut.material.util.JSONResult;
import com.sdut.material.util.LayUITableResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Yu
 * @since 2022-04-20
 */
@Controller
@RequestMapping("/input")
public class InputController {
    @Autowired
    private IInputService inputService;
    @RequestMapping("/getInputListPage")
    public String getInputListPage() {
        return "input/input_list";
    }
    @RequestMapping("/selectByPage")
    @ResponseBody
    public LayUITableResult selectByPage(Long page,Long limit) {
        return inputService.selectByPage(page,limit);
    }
    @RequestMapping("/insert")
    @ResponseBody
    public JSONResult insert(Input input) {
        inputService.insert(input);
        return JSONResult.ok("添加成功");
    }
    @RequestMapping("/inputRepository")
    @ResponseBody
    public JSONResult inputRepository(Integer inputId) {
        return inputService.inputRepository(inputId);
    }
    @RequestMapping("/cancelById")
    @ResponseBody
    public JSONResult cancelById(Integer inputId) {
        inputService.cancelById(inputId);
        return JSONResult.ok("取消成功");
    }
    @RequestMapping("/cancelAll")
    @ResponseBody
    public JSONResult cancelAll(String ids) {
        String[] idArray = ids.split(",");
        for (String inputId : idArray) {
            cancelById(Integer.parseInt(inputId));
        }
        return JSONResult.ok("取消成功");
    }
}

